home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12104 < prev    next >
Encoding:
Text File  |  1996-08-05  |  968 b   |  48 lines

  1. Path: anise.age.uiuc.edu!isa5224
  2. From: isa5224@age2.age.uiuc.edu (Irfan S. Ahmad)
  3. Newsgroups: comp.lang.c
  4. Subject: Int to Double, Pl Advise!
  5. Date: Fri, 29 Mar 1996 04:18:02 GMT
  6. Organization: Univeristy of Illinois
  7. Message-ID: <isa5224.544.315B647A@age2.age.uiuc.edu>
  8. NNTP-Posting-Host: anise.age.uiuc.edu
  9. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #1]
  10.  
  11. Hi:
  12.  
  13. I am having problems with the following type conversion.  From int to double.  
  14. If someone can comment:
  15.  
  16. #define Ng 4
  17. #define Nr 4
  18.  
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <malloc.h> 
  22.  
  23. int p0[Ng][Nr];
  24.  
  25. int main(){
  26. int i,j,k;  
  27. float x =0;
  28. float y =0; 
  29. :
  30. :
  31. :
  32. for (i=1; i<Ng; i++) { 
  33.     for (j=1; j<Nr; j++) {
  34.    
  35.      x = x + ((double) p0[i,j]) / (double)(j*j); }
  36. }
  37.  
  38. I get the following compilation error(s) on MS C++ compiler:
  39. error C2440: 'cast' : cannot convert from 'int [4]' to 'double '
  40.  
  41.  
  42. Please post or preferably email your comments to:
  43. isa5224@sugar.age.uiuc.edu
  44.  
  45. Thanks.
  46.  
  47. Irfan
  48.